package com.rock.code.common.comm;

import java.util.*;

public class QuartzUtil
{
  public static int SECOND = 1;
  public static int MINUTE = 2;
  public static int HOUR = 3;

  public List<Date> getExeTimes(String paramString, Date paramDate1, Date paramDate2)
  {
    ArrayList localArrayList = new ArrayList();
    try
    {
      CronExpressionEx localCronExpressionEx = new CronExpressionEx(paramString.trim());
      Calendar localCalendar1 = Calendar.getInstance();
      Calendar localCalendar2 = Calendar.getInstance();
      localCalendar1.setTime(paramDate1);
      localCalendar2.setTime(paramDate2);
      long l1 = localCalendar1.getTimeInMillis();
      long l2 = localCalendar2.getTimeInMillis();
      l1 -= 1L;
      localCalendar1.setTimeInMillis(l1);
      paramDate1 = localCalendar1.getTime();
      while (l1 < l2)
      {
        paramDate1 = localCronExpressionEx.getNextValidTimeAfter(paramDate1);
        localCalendar1.setTime(paramDate1);
        l1 = localCalendar1.getTimeInMillis();
        if (l1 > l2)
          continue;
        localArrayList.add(paramDate1);
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return localArrayList;
  }

  public List<Date> getExeTimes(String paramString, Date paramDate1, Date paramDate2, Date paramDate3)
  {
    String[] arrayOfString = paramString.split(" ");
    if (arrayOfString[3].contains("/"))
      return getExeTimes(paramString, paramDate3, paramDate2);
    return getExeTimes(paramString, paramDate1, paramDate2);
  }

  public String getChangedQuartz(String paramString, int paramInt1, int paramInt2)
  {
    String str1 = "";
    try
    {
      CronExpressionEx localCronExpressionEx = new CronExpressionEx(paramString.trim());
      Object localObject = new TreeSet();
      String str2 = "";
      switch (paramInt1)
      {
      case 1:
        localObject = localCronExpressionEx.getSecondsSet();
        str2 = localCronExpressionEx.getSecondsExp();
        if (str2.contains("/"))
        {
          localCronExpressionEx.setSecondsExp(splitCronToNewMM(str2, paramInt2));
          str1 = localCronExpressionEx.getCronFromST();
        }
        else if (str2.equals("*"))
        {
          str1 = paramString;
        }
        else
        {
          localCronExpressionEx.setSecondsSet((TreeSet)changeMinsAndSecs((Set)localObject, paramInt2));
          str1 = localCronExpressionEx.getCronFromSet();
        }
        break;
      case 2:
        localObject = localCronExpressionEx.getMinutesSet();
        str2 = localCronExpressionEx.getMinutesExp();
        if (str2.contains("/"))
        {
          localCronExpressionEx.setMinutesExp(splitCronToNewMM(str2, paramInt2));
          str1 = localCronExpressionEx.getCronFromST();
        }
        else if (str2.equals("*"))
        {
          str1 = paramString;
        }
        else
        {
          localCronExpressionEx.setMinutesSet((TreeSet)changeMinsAndSecs((Set)localObject, paramInt2));
          str1 = localCronExpressionEx.getCronFromSet();
        }
        break;
      case 3:
        localObject = localCronExpressionEx.getHoursSet();
        str2 = localCronExpressionEx.getHoursExp();
        if (str2.contains("/"))
        {
          localCronExpressionEx.setHoursExp(splitCronToNewH(str2, paramInt2));
          str1 = localCronExpressionEx.getCronFromST();
        }
        else if (str2.equals("*"))
        {
          str1 = paramString;
        }
        else
        {
          localCronExpressionEx.setHoursSet((TreeSet)changeHours((Set)localObject, paramInt2));
          str1 = localCronExpressionEx.getCronFromSet();
        }
        break;
      case 4:
        new String();
        break;
      case 5:
        new String();
        break;
      case 6:
        new String();
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return ((String)str1);
  }

  protected String splitCronToNewMM(String paramString, int paramInt)
  {
    String[] arrayOfString = paramString.split("/");
    paramString = formatMinsAndSecs(Integer.valueOf(Integer.parseInt(arrayOfString[0]) + paramInt)) + "/" + arrayOfString[1];
    return paramString;
  }

  protected String splitCronToNewH(String paramString, int paramInt)
  {
    String[] arrayOfString = paramString.split("/");
    paramString = formatHours(Integer.valueOf(Integer.parseInt(arrayOfString[0]) + paramInt)) + "/" + arrayOfString[1];
    return paramString;
  }

  protected Set changeHours(Set paramSet, int paramInt)
  {
    TreeSet localTreeSet = new TreeSet();
    if (paramSet.contains(CronExpressionEx.ALL_SPEC))
      return paramSet;
    Iterator localIterator = paramSet.iterator();
    while (localIterator.hasNext())
    {
      Integer localInteger = (Integer)localIterator.next();
      localInteger = Integer.valueOf(formatHours(Integer.valueOf(localInteger.intValue() + paramInt)));
      localTreeSet.add(localInteger);
    }
    return localTreeSet;
  }

  protected Set changeMinsAndSecs(Set paramSet, int paramInt)
  {
    TreeSet localTreeSet = new TreeSet();
    if (paramSet.contains(CronExpressionEx.ALL_SPEC))
      return paramSet;
    Iterator localIterator = paramSet.iterator();
    while (localIterator.hasNext())
    {
      Integer localInteger = (Integer)localIterator.next();
      localInteger = Integer.valueOf(formatMinsAndSecs(Integer.valueOf(localInteger.intValue() + paramInt)));
      localTreeSet.add(localInteger);
    }
    return localTreeSet;
  }

  protected int formatMinsAndSecs(Integer paramInteger)
  {
    if (paramInteger.intValue() >= 60)
      paramInteger = Integer.valueOf(formatMinsAndSecs(Integer.valueOf(paramInteger.intValue() - 60)));
    if (paramInteger.intValue() < 0)
      paramInteger = Integer.valueOf(formatMinsAndSecs(Integer.valueOf(60 + paramInteger.intValue())));
    return paramInteger.intValue();
  }

  protected int formatHours(Integer paramInteger)
  {
    if (paramInteger.intValue() >= 24)
      paramInteger = Integer.valueOf(formatHours(Integer.valueOf(paramInteger.intValue() - 24)));
    if (paramInteger.intValue() < 0)
      paramInteger = Integer.valueOf(formatHours(Integer.valueOf(24 + paramInteger.intValue())));
    return paramInteger.intValue();
  }

  protected int formatWeek(Integer paramInteger)
  {
    if (paramInteger.intValue() >= 8)
      paramInteger = Integer.valueOf(formatWeek(Integer.valueOf(paramInteger.intValue() - 7)));
    if (paramInteger.intValue() < 0)
      paramInteger = Integer.valueOf(formatWeek(Integer.valueOf(8 + paramInteger.intValue())));
    return paramInteger.intValue();
  }
}

/* Location:           C:\Users\think\Desktop\新建文件夹 (2)\bomc-web.jar
 * Qualified Name:     com.sitech.ibnms.util.QuartzUtil
 * JD-Core Version:    0.5.3
 */